//MyAnotherAdvice.java
package org.example.demo3.spring;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component("myAnotherAdvice")
@Aspect
public class MyAnotherAdvice {
    //切点
    @Before("execution(* org.example.demo3.spring.MyMath.add(..))")
    public void before(){
        System.out.println("我的另一个前置增强");
    }

    @AfterReturning("execution(* org.example.demo3.spring.MyMath.subtract(..))")
    public void after(){
        System.out.println("我的另一个后置增强");
    }

    @Around("execution(* org.example.demo3.spring.MyMath.multiply(..))")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("环绕增强开始了");
        Object result = pjp.proceed();
        System.out.println("环绕增强结束了");
        return result;
    }

}
